package com.manpower.adapter;

import java.util.ArrayList;

import com.manpower.data.RegionalStatisticalData;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class RegionalStatisticalAdapter extends BaseAdapter{

	private Context mContext;
	private ArrayList<RegionalStatisticalData> mDatas;
	
	public RegionalStatisticalAdapter(Context context, ArrayList<RegionalStatisticalData> datas) {
		this.mContext = context;
		this.mDatas = datas;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mDatas.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mDatas.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null) {
			RegionalStatisticalItemView itemView = new RegionalStatisticalItemView(mContext);
			itemView.updateView(mDatas.get(position));
			convertView = itemView;
		}
		else {
			((RegionalStatisticalItemView)convertView).updateView(mDatas.get(position));
		}
		return convertView;
	}

}
